Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gerard/4372 intersection issue found using create bar #4527

Merged

Conversation

ggartside
Copy link
Collaborator

@ggartside ggartside commented Feb 3, 2022

Pull request overview

Fixes an issue revealed by surface matching when small surfaces created in intersection were reduced to 0 area surfaces and discarded. The tolerance used in removeSpikesEx should have been the same value as the amount used to shrink and expand surfaces to remove spikes

PR includes the fix (one line change) a test model and a unit test in Model_Gtest to verify the surfaces are paired correctly

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@ggartside
Copy link
Collaborator Author

ggartside commented Feb 3, 2022

The issue was a fault in removeSpikesEx. In this method a polygon is expanded by amount and then shrunk by amount to remove small spikes, the resulting vertices were compared to the original vertices and adjusted accordingly so that the original coordinates could be returned wherever possible. The tolerance used to compare vertices was too large and resulted in the polygon being reduced to a 0 area polygon and rejected. By changing the tolerance to the amount expanded and shrunk the issue was fixed.

Polygons are rejected based on area tolerance in intersection - they have to be greater than tol * tol which is 100mm2, surface matching uses a linear tolerance of 0.01, 10mm. If a polygon is rejected because it is less than 100mm2 it is possible that vertices in that polygon could be > 10mm apart and hence surface matching could fail under certain circumstances.

Currently, if two identical surfaces are intersected their vertices are not changed by the intersection method, which makes perfect sense. However if two almost identical surfaces are intersected and the resulting difference between them is too small to be considered then the original surface vertices are not changed either even though they are slightly different.

These two surfaces are therefore considered to be identical after intersection is performed but may not be considered identical as far as surface matching is concerned (because they are not identical)

To eliminate this error intersection should always return two identical surfaces that will be determined to be equal when passed to circularEqual

@tijcolem tijcolem added severity - Major Bug component - Utilities Geometry Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Feb 4, 2022
@ggartside
Copy link
Collaborator Author

I resolved the two test fails. One of them was caused by adding the circularEqual test in Surface intersect. The circulaEqual is removing inline points and so the count of vertices dropped from 6 to 4. This may be an unwanted artifact so to be prudent it was removed

Copy link
Collaborator

@jmarrec jmarrec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor changes, otherwise everything looks good!

src/model/test/Model_GTest.cpp Show resolved Hide resolved
src/model/test/Model_GTest.cpp Outdated Show resolved Hide resolved
src/model/test/Model_GTest.cpp Outdated Show resolved Hide resolved
src/model/test/Model_GTest.cpp Outdated Show resolved Hide resolved
src/model/test/Model_GTest.cpp Outdated Show resolved Hide resolved
src/model/test/Model_GTest.cpp Outdated Show resolved Hide resolved
src/model/test/Model_GTest.cpp Outdated Show resolved Hide resolved
src/model/test/Space_GTest.cpp Show resolved Hide resolved
src/utilities/geometry/Intersection.cpp Outdated Show resolved Hide resolved
ggartside and others added 10 commits February 9, 2022 10:24
…nce th eorder the polygons are generated in such that newPolygons[0][ and newPolygons[1] are swapped
Yeah my bad :(

Co-authored-by: Julien Marrec <[email protected]>
I presume nameString() calls name().value()?

I will use nameString() in future - less typing

Co-authored-by: Julien Marrec <[email protected]>
Copy link
Collaborator

@tijcolem tijcolem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarrec Thanks for reviewing. Just running the windows CI again and if that passed I'll merge.

@tijcolem tijcolem merged commit e7ec8d4 into develop Feb 18, 2022
@tijcolem tijcolem deleted the gerard/4372_Intersection-issue-found-using-create-bar branch February 18, 2022 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - Utilities Geometry Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Major Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intersection issue found when using create bar
4 participants